
 glm1 <- lm(g2 ~ g1, data=d1)
pdf("testfit.pdf");
plot(g1,g2)
points(g1, glm1$fitted.values, type = "l")
dev.off();



pdf("testfit.pdf");
i<-1
seed0<-0
while(i<nrow(data))
{
        if(data[i,6] == 0)
		{
			seed0<-seed0+1
			print(seed0)
			 g1<-as.numeric(t(as.matrix(overall1[,paste("g",data[i,2],sep="_")])))
			 g2<-as.numeric(t(as.matrix(overall1[,data[i,1]])))
			 glm1 <- lm(g2 ~ g1)
			plot(g1,g2,xlab="gene Exp",ylab="genotype dosage",xlim=c(4,16),ylim=c(0,2))
			points(g1, glm1$fitted.values, type = "l")
			snp_name<-paste("genotype",data[i,1],sep='=')
			gene_name<-paste("gene",data[i,2],sep='=')
			pvalue<-paste("P-value",data[i,4],sep='=')
			iscis<-paste("ISCIS",data[i,6],sep='=')
			legend("topright",inset=.01, legend=c(snp_name,gene_name,pvalue,iscis))
			
		}
		if(seed0 == 50)
		{
			break;
		}
		i<-i+1
}
print("printing cis graph")
seed1<-0
i<-1
while(i<nrow(data))
{
		if(data[i,6] == 1 )
		{
			seed1<-seed1+1
			print(seed1)
			 g1<-as.numeric(t(as.matrix(overall1[,paste("g",data[i,2],sep="_")])))
			 g2<-as.numeric(t(as.matrix(overall1[,data[i,1]])))
			 glm1 <- lm(g2 ~ g1)
			plot(g1,g2,xlab="gene Exp",ylab="genotype dosage",xlim=c(4,16),ylim=c(0,2))
			points(g1, glm1$fitted.values, type = "l")
			snp_name<-paste("genotype",data[i,1],sep='=')
			gene_name<-paste("gene",data[i,2],sep='=')
			pvalue<-paste("P-value",data[i,4],sep='=')
			iscis<-paste("ISCIS",data[i,6],sep='=')
			legend("topright",inset=.01, legend=c(snp_name,gene_name,pvalue,iscis))
			
		}
		if(seed1 == 50)
		{
			break;
		}
		i<-i+1
}
dev.off();